from peewee import *
from .order import OrderItem
from .base import BaseModel, User, Item
from datetime import datetime

class Cate(BaseModel):
    id: int = AutoField(primary_key=True)
    name: str = CharField(default='')
    image: str = CharField(default='')
    desc: str = CharField(default='')
    class Meta:
        table_name = 'item_cate'

class ItemComment(BaseModel):
    order_item_id: int = ForeignKeyField(OrderItem, to_field='id', backref='comment', primary_key=True)
    item_id: int = ForeignKeyField(Item, to_field='id', backref='comments')
    user_id: int = ForeignKeyField(User, to_field='id', backref='comments')
    star: int = IntegerField(default=0)
    state: int = IntegerField(default=0)
    content: str = CharField(default='')
    reply: str = CharField(default='')
    create_at: int = IntegerField(default=datetime.now().timestamp())  # 创建时间
    reply_at: int = IntegerField(default=0)  # 更新时间
    class Meta:
        table_name = 'item_comment'
